﻿using Shop.RemoteModel.LogisticsTemplate.Model;
using Shop.StoreGatewayModular.Interface;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    /// <summary>
    /// 物流摸版
    /// </summary>
    [ApiRouteName("/shop/logistics/template/{name}")]
    internal class LogisticsTemplateApi : ApiController
    {
        private readonly ILogisticsTemplateService _Service;

        public LogisticsTemplateApi (ILogisticsTemplateService service)
        {
            this._Service = service;
        }
        /// <summary>
        /// 新增物流摸版
        /// </summary>
        /// <param name="datum"></param>
        /// <returns></returns>
        public long Add (LogisticsTemplateDatum datum)
        {
            return this._Service.Add(datum);
        }
        /// <summary>
        /// 获取启用可选取的物流费用摸版
        /// </summary>
        /// <returns></returns>
        public LogisticsItem[] GetItems ()
        {
            return this._Service.GetItems();
        }
        /// <summary>
        /// 删除物流摸版
        /// </summary>
        /// <param name="id"></param>
        public void Delete ([NumValidate("shop.logistics.template.id.error", 1)] long id)
        {
            this._Service.Delete(id);
        }
        /// <summary>
        /// 获取物流摸版
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public LTemplateDatum Get ([NumValidate("shop.logistics.template.id.error", 1)] long id)
        {
            return this._Service.Get(id);
        }
        /// <summary>
        /// 查询物流摸版
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public PagingResult<LTemplateDatum> Query (PagingParam<LTQueryParam> param)
        {
            return this._Service.Query(param);
        }
        /// <summary>
        /// 设置物流摸版
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public bool Set (LongParam<LogisticsTemplateDatum> param)
        {
            return this._Service.Set(param.Id, param.Value);
        }
        /// <summary>
        /// 设为默认摸版
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public long SetIsDefault ([NumValidate("shop.logistics.template.id.error", 1)] long id)
        {
            return this._Service.SetIsDefault(id);
        }
        /// <summary>
        /// 设为是否启用
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public bool SetIsEnable (LongParam<bool> param)
        {
            return this._Service.SetIsEnable(param.Id, param.Value);
        }
    }
}
